<%layout("/common/_layout.html"){%>
<%#ajax userTable:{%>
<div class="am-cf am-padding" style="padding:1rem 1.6rem 1.6rem 1rem;margin:0px;"> <!--  padding:1px 2px 3px 4px;上、右、下,和左   -->
  <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">系统管理</strong> / <small>基础数据配置</small></div>
</div>
 <div class="am-g">
    <div class="am-u-sm-12">
        <form class="am-form" id="listForm" action="${base}/sysCodeType/list" method="post">
        <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
        <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
          <tbody>
          <tr>
              <th class="am-text-middle">名称</th>
              <td>
              <div class="am-u-sm-10">
                  <input type="text" id="name" class="am-form-field am-input-sm" value="${name!}" maxlength="60" />
                </div>
            </td>
            <th class="am-text-middle">编码</th>
              <td>
                <div class="am-u-sm-10">
                  <input type="text" id="code" class="am-form-field am-input-sm" value="${code!}" maxlength="60" />
                </div>
              </td>
            </tr>
            <tr>
              <th class="am-text-middle">值</th>
              <td >
                <div class="am-u-sm-10">
                  <input type="text" id="value" class="am-form-field am-input-sm" value="${value!}" maxlength="60" />
                </div>
              </td>
              <th class="am-text-middle">是否有效</th>
              <td>
                <div class="am-u-sm-10">
                  <select data-am-selected id="is_deleted" name="is_deleted">
                        <option value="-1" <%if(is_deleted! == "-1") {%>selected<%}%>>全部</option>
                        <option value="0" <%if(is_deleted! == "0") {%>selected<%}%>>有效</option>
                        <option value="1" <%if(is_deleted! == "1") {%>selected<%}%>>无效</option>
                   </select>
                </div>
              </td>
            </tr>
            <tr>
                <td colspan="4">
                  <div align='right'>
                    <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="submit-btn">搜索</button>
                  </div>
                </td>
            </tr>
          </tbody>
        </table>
      </form>
    </div>
   <div class="am-u-sm-12 am-u-md-12" style="padding:0 1.6rem 1.6rem 1rem;margin:0;">
      <div class="am-btn-toolbar" style="padding-left:.5rem;">
        <div class="am-btn-group am-btn-group-xs">
        <%if(so.hasPermission("CODE_TYPE_ADD")) {%>
            <button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/sysCodeType/add'"><span class="am-icon-plus"></span> 新增</button>
        <%}%>
        <%if(so.hasPermission("CODE_TYPE_DELETE")) {%>
            <button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default" onclick="deleteAll('${base}/sysCodeType/delete')"><span class="am-icon-trash-o"></span> 删除</button>
        <%}%> 
        </div>
      </div>
    </div>
 </div>
  <div class="am-g">
    <div class="am-u-sm-12">
    <div class="am-scrollable-horizontal">
      <table class="am-table am-table-striped am-table-hover table-main">
        <thead>
          <tr class="am-text-nowrap">
             <th class="table-check"><input type="checkbox" id="allCheck"></th>
             <th class="table-title">名称</th>
             <th class="table-title">编码</th>
             <th class="table-title">值</th>
             <th class="table-title">是否有效</th>
             <th class="table-title">排序</th>
             <th class="table-title">创建人</th>
             <th class="table-date">创建时间</th>
             <th class="table-title">最近更新人</th>
             <th class="table-date">最近更新时间</th>
             <th class="table-title">备注</th>
             <th class="table-set">操作</th>
          </tr>
        </thead>
        <tbody>
       <%for(list in pager.list!){%>
         <tr>
           <td><input type="checkbox" <%{%>name="ids" value="${list.id}"<%}%> /></td>  
           <td>${list.name}</td>
           <td>${list.code}</td>
           <td>${list.value}</td>
           <td>
           <%if(list.is_deleted == false){%>
           		是
           <%}else{%>
           		否
           <%}%>
           </td>
           <td>${list.sort}</td>
           <td>${list.creator}</td>
           <td>${list.created_time, dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
           <td>${list.updator}</td>
           <td>${list.last_updated_time, dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
           <td>${list.remark}</td>
           <td>
             <div class="am-btn-toolbar">
               <div class="am-btn-group am-btn-group-xs">
                <%if(so.hasPermission("CODE_TYPE_EDIT")) {%>                   
                 <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="location.href='${base}/sysCodeType/edit?id=${list.id}'"><span class="am-icon-pencil-square-o"></span>编辑</button>
               <%}%>
               </div>
             </div>
           </td>
         </tr>
       <%}%> 
     </tbody>
     </table>
     </div>
      <div class="am-cf">
         <!-- 分页 -->
         <%if (pager.list.~size > 0){%>
             <div class="am-fr">
                 <% include("/admin/common_pager.tpl"){}%>
             </div>
         <%}else{%>
             <div class="am-kai">
               <h3>没有找到任何记录!</h3>
             </div>
         <%}%>
      </div>
    
    </div>
  </div>

<script type="text/javascript">
    $(function(){
      var keywordsObj = {};
      $("#submit-btn").on("click",function(){
        if($("#code").val())
          keywordsObj.code = $("#code").val();
        if($("#value").val())
            keywordsObj.value = $("#value").val();
        if($("#name").val())
          keywordsObj.name = $("#name").val();
        if($("#is_deleted").val())
          keywordsObj.is_deleted = $("#is_deleted").val();

        var keywords = "";
        if(!$.isEmptyObject(keywordsObj)){
          keywords = JSON.stringify(keywordsObj);
        }
        console.log("keywords = "+ keywords);

        $("#keywords").val(keywords);
        $("#listForm").submit();
      });
    });
  </script>
  <%}%>
<%}%>
